<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="pageList">
      <el-table-column label="序号" align="center" type="index" width="100" />
      <el-table-column
        label="定时任务"
        align="center"
        prop="name"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="描述"
        align="center"
        prop="remark"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template #default="scope">
          <el-button
            type="primary"
            plain
            icon="Refresh"
            @click="handleDoTask(scope.row)"
 
            >手动执行</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup name="Task">
import { goodsSumTrigger } from "@/api/business/goods";
import { moneyTrigger } from "@/api/business/ranking";
import { changeClean } from "@/api/business/order";

const { proxy } = getCurrentInstance();

const pageList = ref([
  {
    id: 1,
    name: "会员等级",
    type: "vip",
    remark: "每月1日02:00刷新",
  },
  {
    id: 2,
    name: "商品销量",
    type: "goodsSum",
    remark: "每月1日02:00刷新",
  },
    {
    id: 3,
    name: "订单",
    type: "order",
    remark: "---",
  },
]);
const loading = ref(false);
const data = reactive({});
const {} = toRefs(data);

/**修改按钮操作 */
function handleDoTask(row) {
  if (row.type === "vip") {
    // moneyTrigger().then((response) => {
    //   if (response.code == 200) {
    //     proxy.$modal.msgSuccess("操作成功");
    //   } else {
    //     proxy.$modal.msgSuccess("失败");
    //   }
    // });
  } else if (row.type === "goodsSum") {
    // goodsSumTrigger().then((response) => {
    //   if (response.code == 200) {
    //     proxy.$modal.msgSuccess("操作成功");
    //   } else {
    //     proxy.$modal.msgSuccess("失败");
    //   }
    // });
  } else if (row.type === "order") {
    changeClean().then((response) => {
      if (response.code == 200) {
        proxy.$modal.msgSuccess("操作成功");
      } else {
        proxy.$modal.msgSuccess("失败");
      }
    });
  }
}
</script>
<style lang="scss" scoped>
.color-blue {
  color: rgb(0, 119, 255);
  cursor: pointer;
}
</style>
